<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Vote
 * @copyright  Copyright 2011 KEENONWEB LLC
 * @license    http://www.keenonweb.com/
 * @version    $Id: categories.tpl 2011-03-09 01:11:30 idris $
 * @author     Idris
 */
?>

<h2><?php echo $this->translate("Voting Plugin") ?></h2>

<?php if( count($this->navigation) ): ?>
<div class='tabs'>
  <?php
      // Render the menu
      //->setUlClass()
  echo $this->navigation()->menu()->setContainer($this->navigation)->render()
  ?>
</div>
<?php endif; ?>

<script type="text/javascript">
var url = "<?php echo $this->url(array('module' => 'vote', 'controller' => 'settings', 'action' => 'categories'), 'admin_default', array('reset' => true)); ?>";
function changeVoteType(selectElement)
{
  selectElement = $(selectElement);
  var type = selectElement.value;
  window.location.href = url + '/type/' + type;
}
</script>

<div class='clear'>
  <div class='settings'>
    <form class="global_form">
      <div>
        <h3><?php echo $this->translate("Voting Categories") ?></h3>

        <p class="description">
          <?php echo $this->translate("VOTING_VIEWS_SCRIPTS_ADMINSETTINGS_CATEGORIES_DESCRIPTION") ?>
        </p>

        <div class="clr"></div>

        <div class="vote-type-switcher">
          <ul>
            <li <?php if ($this->type == 'photo'): ?> class="active" <?php endif; ?>><?php echo $this->htmlLink($this->url(array('module' => 'vote', 'controller' => 'settings', 'action' => 'categories', 'type' => 'photo'), 'admin_default', array('reset' => true)), $this->translate('vote_Photo')); ?></li>
            <li <?php if ($this->type == 'video'): ?> class="active" <?php endif; ?>><?php echo $this->htmlLink($this->url(array('module' => 'vote', 'controller' => 'settings', 'action' => 'categories', 'type' => 'video'), 'admin_default', array('reset' => true)), $this->translate('vote_Video')); ?></li>
            <li <?php if ($this->type == 'music'): ?> class="active" <?php endif; ?>><?php echo $this->htmlLink($this->url(array('module' => 'vote', 'controller' => 'settings', 'action' => 'categories', 'type' => 'music'), 'admin_default', array('reset' => true)), $this->translate('vote_Music')); ?></li>
          </ul>
        </div>

        <div class="clr"></div>

        <br />

        <?php if (count($this->categories) > 0): ?>

        <table class='admin_table'>
          <thead>

          <tr>
            <th><?php echo $this->translate("Category Name") ?></th>
            <th><?php echo $this->translate("Number of Times Used") ?></th>
            <th><?php echo $this->translate("Options") ?></th>
          </tr>

          </thead>
          <tbody>
          <?php foreach ($this->categories as $category): ?>

          <tr>
            <td><?php echo $category->category_name?></td>
            <td><?php echo $category->getUsedCount()?></td>
            <td>
              <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'vote', 'controller' => 'settings', 'format' => 'smoothbox', 'action' => 'edit-category', 'id' => $category->category_id), $this->translate('edit'), array(
              'class' => 'smoothbox',
              )) ?>
              |
              <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'vote', 'controller' => 'settings', 'format' => 'smoothbox', 'action' => 'delete-category', 'id' => $category->category_id), $this->translate('delete'), array(
              'class' => 'smoothbox',
              )) ?>

            </td>
          </tr>

          <?php endforeach; ?>
          </tbody>
        </table>
        <?php else:?>
        <br/>

        <div class="tip">
          <span><?php echo $this->translate("There are currently no categories.") ?></span>
        </div>
        <?php endif;?>
        <br/>
        <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'vote', 'controller' => 'settings', 'action' => 'add-category', 'type' => $this->type, 'format' => 'smoothbox'), $this->translate('Add New Category'), array(
        'class' => 'smoothbox buttonlink',
        'style' => 'background-image: url(application/modules/Core/externals/images/admin/new_category.png);')) ?>
      </div>
    </form>
  </div>
</div>